home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
-
- mac_windows.c: Copyright (c) Kevin Hammond 1993. All rights reserved.
-
- This module contains code to handle window display, update, creation etc.
-
- *****************************************************************************/
-
- #include "mac.h"
- #include <string.h>
- #include <AppleEvents.h>
-
- #pragma segment Windows
-
- extern CursHandle watchcurs; /* Watch cursor */
- extern EventRecord myEvent; /* Global Event Record */
- extern Boolean CIAvailable; /* Are colour icons available */
-
-
- /*
- Window-handling routines.
- */
-
-
- #define NUM_WINDOWS 64 /* How many windows at a maximum */
- #define NUM_SYS_WINDOWS 2 /* How many of these are system windows */
- #define ILLEGAL_WINDOW (-1) /* The value that means "not one of our windows" */
-
-
- struct WindowStruct WindowRec[NUM_WINDOWS]; /* The window record array */
-
- int thefrontwindow = ILLEGAL_WINDOW; /* FrontWindow() cache */
- DescType savemethod = kAEAskUser; /* How to save files on quit */
-
- /* Forward declarations */
- extern char *safemalloc();
-
- extern short findmenuitem();
-
- extern Boolean scrapVisible;
-
- extern Boolean isVolLocked(), isUserLocked();
-
-
-
- /****************************************************************************
-
- Window attribute setting.
-
- ****************************************************************************/
-
-
- /*
- This routine is called when a window is saved. The SAVED flag is
- set, and the appropriate menu item reverted to normal.
- */
-
- saved(i)
- {
- if(isEditWindow(i) && OPEN(i) && !SAVED(i) && FILENAME(i) != NIL)
- {
- char wtitle[256];
- short menuitem;
- getwtitle(WINDOW(i),wtitle);
- if((menuitem = findmenuitem(Menu_Window,3,1024,wtitle)) >= 3)
- SetItemStyle(Menu_Window,menuitem,normal);
- }
-
- if(isLegalWindow(i))
- {
- FLAGS(i) |= WSAVED;
- FLAGS(i) &= ~WVIRGIN;
- }
- }
-
-
- /*
- This routine is called when any changes are made to a TE
- buffer. The SAVED flag is unset, and the appropriate menu
- item underlined.
-
- We do not bother underlining already changed windows, nor do
- we record that the worksheet has been changed. The worksheet
- is purely a scratch area, so loss should not be as important
- as a document.
-
- Changed this to record worksheet changes -- KH, V 0.04.
- */
-
-
- changed(i)
- {
- if(isEditWindow(i) && OPEN(i))
- {
- if(SAVED(i))
- {
- char wtitle[256];
- short menuitem;
- getwtitle(WINDOW(i),wtitle);
- if((menuitem = findmenuitem(Menu_Window,3,1024,wtitle)) >= 3)
- SetItemStyle(Menu_Window,menuitem,underline);
- FLAGS(i) &= ~WSAVED;
- }
- }
- }
-
-
- /*
- Records that a window has been created (or OPENED).
- */
-
- opened(i)
- {
- if(isLegalWindow(i))
- FLAGS(i) |= WOPEN;
- }
-
-
- /*
- A window has been closed.
- The worksheet and clipboard are never closed this way.
- */
-
- closed(i)
- {
- if(isDocumentWindow(i))
- FLAGS(i) &= ~WOPEN;
- }
-
- /*
- This sets the version number for a window.
-
- Versions are used if there are multiple windows with the
- same name.
- */
-
- setversion(i,vers)
- {
- if(isDocumentWindow(i))
- {
- FLAGS(i) &= ~WVERSMASK;
- FLAGS(i) |= (vers << (WVERS-1)) & WVERSMASK;
- }
- }
-
-
-
- /*
- Set the title and filename of an existing window record.
-
- Adjust other windows with the same filename
- to reflect the version changes.
- */
-
-
- setwindowtitle(windex,title)
- int windex;
- char *title;
- {
- char *newtitle = safemalloc(strlen(title)+1);
- strcpy(newtitle,title);
- if(FILENAME(windex) != NIL)
- free(FILENAME(windex));
- FILENAME(windex) = newtitle;
- setwtitle(WINDOW(windex),title);
-
- if(findHighestVersion(title) > 0)
- resetversions(title,windex);
- }
-
-
- /****************************************************************************
-
- Locating windows according to various criteria.
-
- ****************************************************************************/
-
-
- /*
- Find the window if it is one of mine.
- */
-
- findMyWindow(window)
- WindowPtr window;
- {
- int w = GetWRefCon(window)-1;
- if(!isLegalWindow(w) || !OPEN(w))
- w = ILLEGAL_WINDOW;
-
- return(w);
- }
-
-
- /*
- Find a window corresponding to a file.
- Use the window title rather than the recorded
- filename if looking for a named window
- (e.g. because selected from the Window menu).
- */
-
- int findMyWindowName(name,volnum,dirID,usewtitle)
- char *name;
- short volnum;
- long dirID;
- Boolean usewtitle;
- {
- int i;
- char *fname;
- char wname[256];
-
- for( i = 0; i < NUM_WINDOWS; ++i )
- if (OPEN(i))
- {
- if(usewtitle)
- {
- getwtitle(WINDOW(i),wname);
- fname = wname;
- }
- else
- fname = FILENAME(i);
-
- if(equalfiles(name,fname) && (usewtitle || (VREFNUM(i) == volnum && DIRID(i) == dirID)))
- return(i);
- }
-
- return( ILLEGAL_WINDOW );
- }
-
-
-
- /****************************************************************************
-
- Window attribute testing.
-
- ****************************************************************************/
-
-
- /*
- Is this a valid window
- */
-
- isValidWindow(whichWindow)
- WindowPtr whichWindow;
- {
- int w = findMyWindow(whichWindow);
- return(isLegalWindow(w));
- }
-
-
- /*
- Is the window iconic.
- */
-
- int iconic(windex)
- int windex;
- {
- return(isLegalWindow(windex) && ICONIC(windex));
- }
-
-
- /*
- Can the window be edited?
-
- Currently true for all non-scrap windows.
- */
-
- isEditWindow(windex)
- int windex;
- {
- return(isLegalWindow(windex) && !isScrapWindow(windex) && !iconic(windex));
- }
-
-
- /*
- Is the window reference in a legal range.
- */
-
- isLegalWindow(windex)
- int windex;
- {
- return(windex >= 0 && windex < NUM_WINDOWS);
- }
-
-
- /*
- Is this the scrap window.
- */
-
- isScrapWindow(windex)
- int windex;
- {
- return(windex == scrap);
- }
-
-
- /*
- Is this a user document window
- */
-
- isDocumentWindow(windex)
- int windex;
- {
- /* ignore worksheet and clipboard windows */
- return(windex > NUM_SYS_WINDOWS-1 && windex < NUM_WINDOWS);
- }
-
-
-
- /****************************************************************************
-
- Initialise Gofer Windows.
-
- Set up the window record and create the initial windows -- worksheet and scrap.
- Initially the scrap (clipboard) window is hidden. The scrap is not added to
- the Window list in the window menu, but all other windows including the Worksheet
- are added.
-
- ****************************************************************************/
-
- Init_Gofer_Windows()
- {
- int i;
-
- for( i=0; i < NUM_WINDOWS; ++i)
- closed(i);
-
- /* The order of opening determines the indexes of these windows. */
- (void) CreateNewWindow(Res_OpenClipboard,"Clipboard",FALSE,FALSE,DONT_POSITION,FALSE);
- (void) CreateNewWindow(Res_OpenWorksheet,"Worksheet",TRUE,TRUE,DONT_POSITION,TRUE);
-
- /*
- Don't wrap worksheet lines -- this way, execution output is not "lost".
- Humayan changed this "for consistency", but Don didn't like it!
- */
-
- (*TEHANDLE(worksheet))->crOnly = 0;
-
- /* The scrap is always locked */
- FLAGS(scrap) |= WVLOCKED;
- }
-
-
- /****************************************************************************
-
- These routines iconise/deiconise windows (collapse windows
- to icons or vice-versa).
-
- ****************************************************************************/
-
-
- static CIconHandle CWindowIcon = NIL;
- static Handle WindowIcon = NIL;
-
- /*
- Initialise the Icon.
- */
-
-
- InitWIcon()
- {
- if (CIAvailable && CWindowIcon == NIL )
- CWindowIcon = GetCIcon(Res_IconWindow);
-
- if(WindowIcon == NIL)
- WindowIcon = GetIcon(Res_IconWindow);
- }
-
-
-
- /*
- Create a new iconic window and position it
- if required.
- */
-
-
- CreateIconWindow(windex,doposition)
- int windex;
- Boolean doposition;
- {
- static Point position = {0,0};
-
- if (isLegalWindow(windex) && ICONWINDOW(windex) == NIL)
- {
- GrafPtr SavePort;
- PicHandle IconPic;
-
- ICONWINDOW(windex) = GetNewWindow(Res_IconiseWindow, NIL, (WindowPtr) -1);
- SetWRefCon(ICONWINDOW(windex),windex+1);
-
- GetPort(&SavePort);
- SetPort(ICONWINDOW(windex));
-
- #if 0
- IconPic = OpenPicture(&ICONWINDOW(windex)->portRect);
- UpdateIconWindow(ICONWINDOW(windex));
- ClosePicture();
- SetWindowPic(ICONWINDOW(windex),IconPic);
- #endif
-
- /* Now position the icon, if requested */
- if(doposition)
- {
- Rect screen;
-
- screen = qd.screenBits.bounds;
- position.h += 40;
- if(position.h > screen.right)
- {
- position.h = screen.left+5;
- position.v += 40;
- if(position.v > screen.bottom)
- position.v = screen.top + 25;
- }
- else if (position.h < screen.left+5)
- position.h = screen.left+5;
-
- if(position.v < screen.top+25 || position.v > screen.bottom - 40)
- {
- position.v = screen.top + 25;
- position.h = screen.left+5;
- }
-
- MoveWindow(ICONWINDOW(windex),position.h,position.v,false);
- }
- SetPort(SavePort);
- }
- }
-
-
-
- /*
- Turn a Window into its Iconic form
- */
-
- IconiseWindow(windex)
- int windex;
- {
- if (isLegalWindow(windex) && !iconic(windex))
- {
- CreateIconWindow(windex,TRUE);
- HideWindow(WINDOW(windex));
- SendBehind(ICONWINDOW(windex),NIL);
- SendBehind(WINDOW(windex),NIL);
- ShowWindow(ICONWINDOW(windex));
- /* SelectWindow(ICONWINDOW(windex));*/
- FLAGS(windex) |= WICONIC;
- AdjustMenus(TRUE);
- }
- }
-
-
- /*
- Turn an Iconic Window back into a normal window form.
- */
-
- DeIconiseWindow(windex)
- int windex;
- {
- if (isLegalWindow(windex) && iconic(windex))
- {
- HideWindow(ICONWINDOW(windex));
- ShowWindow(WINDOW(windex));
- SelectWindow(WINDOW(windex));
- SendBehind(ICONWINDOW(windex),NIL);
- FLAGS(windex) &= ~WICONIC;
- AdjustMenus(TRUE);
- }
- }
-
-
- /*
- Iconise all windows.
- */
-
- IconiseAll()
- {
- int i;
- for( i = 0; i < NUM_WINDOWS; ++i)
- if(OPEN(i))
- IconiseWindow(i);
- }
-
-
-
- /****************************************************************************
-
- Window Creation.
-
- ****************************************************************************/
-
-
- /*
- Get a window record and initialise it.
- Again, I'm seriously paranoid.
- */
-
- int CreateMyWindow()
- {
- int i;
-
- for(i=0; i < NUM_WINDOWS; ++i)
- if(EMPTY(i))
- {
- initWindowRec(i);
- opened(i);
- return(i);
- }
- AbortError("","No more windows can be created -- Please close some open windows first");
- return(ILLEGAL_WINDOW);
- }
-
-
- /*
- Initialse the window record for window "i".
- */
-
- initWindowRec(i)
- int i;
- {
- FILENAME(i) = NIL;
- WINDOW(i) = NIL;
- ICONWINDOW(i) = NIL;
- TEHANDLE(i) = NIL;
- TELOCK(i) = 0;
- HSCROLL(i) = NIL;
- VSCROLL(i) = NIL;
- VREFNUM(i) = 0;
- DIRID(i) = 0;
- FLAGS(i) = (WSAVED | WVIRGIN);
- }
-
-
-
- /*
- Position a new window nicely (...or so we hope).
- Note that this assumes we have a new window, with the application font set
- For best results, the window should not be visible.
- */
-
- #define POSITION_NUM_WINDOWS 4
- #define POSITION_WINDOW_DELTAH 8
- #define POSITION_WINDOW_DELTAV 4
- #define POSITION_SCREEN_INSET 4
-
- void PositionNewWindow(window,positionIndex)
- WindowPtr window;
- short positionIndex;
- {
- Point offsetPt;
- Rect windowR;
- FontInfo sysFontInfo;
- GrafPtr saveport;
-
- /* Wrap position index so at least POSITION_NUM_WINDOWS windows can be shown neatly */
- positionIndex = (positionIndex % POSITION_NUM_WINDOWS) + 1;
-
- /* We need a grafport so we can do some detective work */
- GetPort(&saveport);
- SetPort(window);
-
- /* Get system font height */
- TextFont(systemFont);
- GetFontInfo(&sysFontInfo);
-
- /* Clean up */
- TextFont(applFont);
- SetPort(saveport);
-
- /* Calculate the offset between windows */
- offsetPt.v = POSITION_WINDOW_DELTAV + (sysFontInfo.ascent + sysFontInfo.descent + sysFontInfo.leading);
- offsetPt.h = offsetPt.v / 2;
-
- /* Figure window rect (on the main screen if multiple monitors) */
- windowR = qd.screenBits.bounds;
- InsetRect(&windowR, POSITION_SCREEN_INSET, POSITION_SCREEN_INSET);
-
- /* Offset the window to the appropriate position */
- windowR.left += offsetPt.h * (positionIndex - 1);
- windowR.top += GetMBarHeight() + (offsetPt.v * positionIndex);
-
- /* And indent the right edge for ease in switching between windows */
- windowR.right -= POSITION_WINDOW_DELTAH * (POSITION_NUM_WINDOWS - positionIndex);
-
- /* Do the real work */
- MoveWindow(window, windowR.left, windowR.top, false);
- SizeWindow(window, windowR.right - windowR.left, windowR.bottom - windowR.top, false);
- }
-
-
- /*
- Create a new window of the given resource type called fname.
- Show it and add it to the window menu if requested.
- */
-
- int CreateNewWindow(windowtype,fname,doshow,windowmenu,doposition,fittoviewrect)
- char *fname;
- Boolean doshow, windowmenu, doposition,fittoviewrect;
- {
- int windex;
- extern short currentfnum, currentfsize;
- WindowPtr whichWindow;
-
- SetCursor(*watchcurs);
-
- windex = CreateMyWindow();
- whichWindow = GetNewWindow(windowtype,NIL, (WindowPtr)-1);
- WINDOW(windex) = whichWindow;
-
- /* Write into the new window */
- SetPort(whichWindow);
-
- /* If requested, position the window neatly */
- if (doposition)
- PositionNewWindow(whichWindow, windex - NUM_SYS_WINDOWS);
-
- /* If the window can be zoomed, set up its zoom rectangles */
- if ( ((WindowPeek)whichWindow)->spareFlag )
- {
- WStateDataHandle stateDataH = (WStateDataHandle)((WindowPeek)whichWindow)->dataHandle;
-
- (**stateDataH).stdState = qd.screenBits.bounds;
- (**stateDataH).stdState.top += 38; /* Note: this should probably be set dynamically */
- InsetRect(&(**stateDataH).stdState, POSITION_SCREEN_INSET, POSITION_SCREEN_INSET);
-
- (**stateDataH).userState = whichWindow->portRect;
- LocalToGlobalRect(&(**stateDataH).userState);
- }
-
- /* Set up text characteristics */
- TextFont(currentfnum);
- TextSize(currentfsize);
-
- /* Open a TE Window */
- NewTERec(windex,fittoviewrect);
-
- /* Horizontal scroll bar */
- HSCROLL(windex) = GetNewControl( Res_HScroll_bar, whichWindow);
-
- /* Vertical scroll bar */
- VSCROLL(windex) = GetNewControl( Res_VScroll_bar, whichWindow);
-
- /* Size the scroll bars */
- ScrollHControl(HSCROLL(windex),whichWindow);
- ScrollVControl(VSCROLL(windex),whichWindow);
-
-
- /* Set the window title and reference */
- setwtitle(whichWindow,fname);
- FILENAME(windex) = safemalloc(strlen(fname)+1);
- strcpy(FILENAME(windex),fname);
- SetWRefCon(whichWindow,windex+1);
-
-
- /* Add this window to the window menu if required */
- if(windowmenu)
- {
- short mitems = CountMItems(Menu_Window);
- char itembuf[256];
- if(mitems < 10 + 3)
- {
- sprintf(itembuf,"/%c%s",mitems+'0'-3,fname);
- insmenuitem(Menu_Window,itembuf,mitems);
- }
- else
- insmenuitem(Menu_Window,fname,mitems);
- setwindowtitle(windex,fname);
- }
-
- /* Show the window if required */
- if(doshow)
- {
- ShowWindow(whichWindow);
- DrawGrowIcon(whichWindow);
- DrawGoferIcons(windex);
- DrawControls(whichWindow);
- ValidRect(&whichWindow->portRect);
- }
-
- InitCursor();
- return(windex);
- }
-
-
-
- /*
- Create a new untitled window.
- */
-
-
- newUntitledWindow()
- {
- static int num_created = 0;
- char file[20];
- sprintf(file,"Untitled%d",++num_created);
- (void) CreateNewWindow(Res_OpenWindow,file,TRUE,TRUE,AUTO_POSITION,FALSE);
- }
-
-
- /****************************************************************************
-
- Handling multiple windows with the same name.
-
- ****************************************************************************/
-
-
- /*
- Return the highest version of a file.
- */
-
- findHighestVersion(title)
- char *title;
- {
- int i;
- int version = -1;
-
- for(i=0; i < NUM_WINDOWS; ++i)
- if(OPEN(i))
- {
- if(equalfiles(title,FILENAME(i)))
- setversion(i,++version);
- }
-
- return(version);
- }
-
-
- /*
- Reset all version numbers. Don't add a version number
- to the name if windex is ILLEGAL_WINDOW.
- */
-
- resetversions(name,windex)
- char *name;
- int windex;
- {
- char wtitle[256];
- int i, version = 0;
- char num[5];
- short menuitem;
- Boolean simpletitle = windex == ILLEGAL_WINDOW &&
- findHighestVersion(name) <= 0;
-
-
- for(i=0; i < NUM_WINDOWS; ++i)
- if(OPEN(i))
- {
- if(equalfiles(name,FILENAME(i)))
- {
- getwtitle(WINDOW(i),wtitle);
- menuitem = findmenuitem(Menu_Window,3,1024,wtitle);
-
- /* Reset the window title */
- strcpy(wtitle,name);
- if(!simpletitle)
- {
- sprintf(num,":%d",VERSION(i)+1);
- strcat(wtitle,num);
- }
-
- setwtitle(WINDOW(i),wtitle);
- setitem(Menu_Window,menuitem,wtitle);
- }
- }
- }
-
-
-
- /****************************************************************************
-
- Closing and disposing of windows.
-
- ****************************************************************************/
-
-
- /*
- Close a window.
- Return FALSE if cancelled, otherwise TRUE.
- */
-
-
- Boolean closethewindow(w,s)
- int w;
- char *s;
- {
- Boolean cancelled = FALSE;
-
- if(isDocumentWindow(w))
- {
- if(savemethod != kAENo && CHANGED(w))
- {
- if((savemethod == kAEAskUser && (cancelled = shouldsavedialog(w,s)) == OK))
- {
- SetCursor(*watchcurs);
- if(!save(w))
- return(FALSE);
- }
- else if (cancelled == CANCEL)
- return(FALSE);
- }
- CloseAWindow(w);
- }
- else if(isScrapWindow(w) && scrapVisible)
- showhideclipboard();
-
- return(TRUE);
- }
-
-
- /*
- Close all windows.
- Return FALSE if cancelled, otherwise TRUE.
- */
-
- Boolean closeallwindows()
- {
- int i;
-
- SetCursor(*watchcurs);
-
- for(i = 0; i < NUM_WINDOWS; ++i)
- if(OPEN(i))
- {
- if(!closethewindow(i,"quitting"))
- return(FALSE);
- SetCursor(*watchcurs);
- }
-
- return(TRUE);
- }
-
-
-
- /*
- Close a window.
-
- Reset versions and delete it from the window menu if necessary.
- */
-
- static char name[256];
-
- CloseAWindow(windex)
- int windex;
- {
- if (isLegalWindow(windex) && OPEN(windex))
- {
- /* Be careful when closing iconic windows! */
- WindowPtr whichWindow = iconic(windex)?ICONWINDOW(windex):WINDOW(windex);
- short menuitem, mitems;
-
- /* Remove the window from the window menu if necessary */
- getwtitle(WINDOW(windex),name);
- menuitem = findmenuitem(Menu_Window,3,1024,name);
- if(menuitem >= 3 && menuitem <= 1027)
- {
- char itemstring[256];
- char keyequiv[3];
- DelMenuItem(Menu_Window,menuitem);
- mitems = CountMItems(Menu_Window);
- while(menuitem < 10+4 && menuitem < mitems+1)
- {
- sprintf(itemstring,"/%c",menuitem+'0'-4);
- getitem(Menu_Window,menuitem,itemstring+2);
- DelMenuItem(Menu_Window,menuitem);
- insmenuitem(Menu_Window,itemstring,menuitem-1);
- ++menuitem;
- }
- }
-
- /*
- Disposing the window causes the window to be deactivated
- and another window to be activated. To avoid referencing
- a dead window in the deactivate we first hide the window,
- then handle the activate/deactivate explicitly.
-
- The Mac interface model ensures no other activate/deactivate will
- intervene -- if one was outstanding, it would have been presented
- before this close event. To be certain, we flush all activate
- events, anyway.
- */
-
- FlushEvents(activMask,0);
-
- /*
- Now we hide the window, which will generate two activate events:
- first a deactivate for the window being hidden,
- then an activate for the window being brought to the front.
- */
-
- HideWindow(whichWindow);
-
- thefrontwindow = ILLEGAL_WINDOW;
-
- /* Mark the window as closed */
- closed(windex);
-
- if (EventAvail(activMask, &myEvent))
- {
- if (myEvent.what == activateEvt && (WindowPtr)myEvent.message == whichWindow)
- (void) GetNextEvent(activMask, &myEvent);
-
- SetMenus(FALSE,windex);
- }
-
-
- if(FILENAME(windex) != NIL)
- resetversions(FILENAME(windex),ILLEGAL_WINDOW);
-
- if(FILENAME(windex)!=NIL)
- {
- free(FILENAME(windex));
- FILENAME(windex)=NIL;
- }
-
- if(TEHANDLE(windex)!=NIL)
- {
- TEDispose(TEHANDLE(windex));
- TEHANDLE(windex) = NIL;
- }
-
- /* Forget the main window */
- SetWRefCon(WINDOW(windex),0);
- DisposeWindow(WINDOW(windex));
-
- /* and do the same for the icon window */
- if(ICONWINDOW(windex)!=NIL)
- {
- SetWRefCon(ICONWINDOW(windex),0);
- /* Also disposes some necessary controls? KH */
- #if 0
- DisposeWindow(ICONWINDOW(windex));
- #endif
- }
-
- initWindowRec(windex);
- }
- }
-
-
- /****************************************************************************
-
- Resizing windows.
-
- ****************************************************************************/
-
- void ValidateGrowIcon()
- /* Validates the current window's grow icon (assumes the current port is a window) */
- {
- Rect growIconR;
-
- growIconR = qd.thePort->portRect;
- growIconR.left = growIconR.right - (SCROLLBARWIDTH - 1);
- growIconR.top = growIconR.bottom - (SCROLLBARWIDTH - 1);
- ValidRect(&growIconR);
- }
-
-
- /*
- Resize a window.
-
- Handles interpreter-created windows as well as application windows.
- */
-
-
- ResizeTheWindow(whichWindow)
- WindowPtr whichWindow;
- {
- WindowPtr SavePort;
- int windex = findMyWindow(whichWindow);
- Rect pr = whichWindow->portRect;
-
- if(iconic(windex))
- return;
-
- SetCursor(*watchcurs);
-
- GetPort(&SavePort); /* Save the current port */
- SetPort(whichWindow); /* Set the port to my window */
-
- /* This is rather clumsy -- Update calls would be better */
- EraseRect(&pr); /* Erase the new window area */
- InvalRect(&pr); /* Set to update the new window area */
-
- DrawGrowIcon(whichWindow);
-
- if (isLegalWindow(windex))
- {
- TEHandle teh = TEHANDLE(windex);
- short first;
-
- DrawGoferIcons(windex);
-
- HLockHigh((Handle)teh);
- first = (*teh)->lineStarts[GetCtlValue(VSCROLL(windex)) - 1];
- CalculateTERects(&(*teh)->viewRect, &(*teh)->destRect, (*teh)->lineHeight, windex==worksheet);
- HUnlock((Handle)teh);
-
- ScrollHControl(HSCROLL(windex),whichWindow);
- ScrollVControl(VSCROLL(windex),whichWindow);
-
- TECalText(teh);
- AdjustScrollBars(windex);
-
- ScrollCharacter(windex,first,FALSE);
- }
-
- SetPort(SavePort); /* Restore the old port */
- InitCursor();
- }
-
-
-
-
- /*
- Resize Horizontal scrollbars.
- */
-
- ScrollHControl(HControl,whichWindow)
- ControlHandle HControl;
- WindowPtr whichWindow;
- {
- Rect tempRect, temp2Rect;
- short Index;
- int windex = findMyWindow(whichWindow);
-
- if (isLegalWindow(windex) && HControl != NIL) /* Only do if the control is valid */
- {
- HLockHigh((Handle)HControl); /* Lock the handle while we use it */
- tempRect = (*HControl)->contrlRect; /* Get the last control position */
- tempRect.top = tempRect.top - 4; /* Widen the area to update */
- tempRect.right = tempRect.right + 16; /* Widen the area to update */
- InvalRect(&tempRect); /* Flag old position for update routine */
- tempRect = (*HControl)->contrlRect; /* Get the last control position */
- temp2Rect = whichWindow->portRect; /* Get the window rectangle */
- Index = temp2Rect.right - temp2Rect.left - 13; /* Get the scroll area width */
-
- /* The scrap has no icons */
- if(windex == scrap)
- /* SKIP */;
-
- /* The worksheet only has one icon */
- else if(windex == worksheet)
- {
- tempRect.left = SMALLICONWIDTH-1; /* Pin at left edge after locked icon */
- Index -= SMALLICONWIDTH-1;
- }
-
- else
- {
- tempRect.left = SMALLICONWIDTH*3-3; /* Pin at left edge after number icon */
- Index -= SMALLICONWIDTH*3-3;
- }
-
- HideControl(HControl); /* Hide it during size and move */
- SizeControl(HControl, Index,16); /* Make it 16 pixels high, std width */
- MoveControl(HControl, tempRect.left-1,temp2Rect.bottom - temp2Rect.top-15);/* Size it correctly */
- ShowControl(HControl); /* Safe to show it now */
- ValidRect(&(*HControl)->contrlRect); /* Notify Window Manager that it's been drawn */
- HUnlock((Handle)HControl); /* Let it float again */
- }
- }
-
-
- /*
- Resize Vertical scrollbars.
- */
-
- ScrollVControl(VControl,whichWindow)
- ControlHandle VControl;
- WindowPtr whichWindow;
- {
- Rect tempRect, temp2Rect;
- short Index;
-
- if (VControl != NIL) /* Only do if the control is valid */
- {
- HLockHigh((Handle)VControl); /* Lock the handle while we use it */
- tempRect = (*VControl)->contrlRect; /* Get the last control position */
- tempRect.top = tempRect.left - 4; /* Widen the area to update */
- tempRect.right = tempRect.bottom + 16; /* Widen the area to update */
- InvalRect(&tempRect); /* Flag old position for update routine */
- tempRect = (*VControl)->contrlRect; /* Get the last control position */
- temp2Rect = whichWindow->portRect; /* Get the window rectangle */
- Index = temp2Rect.bottom - temp2Rect.top - 13; /* Get the scroll area width */
- tempRect.top = 0; /* Pin at left edge */
- HideControl(VControl); /* Hide it during size and move */
- SizeControl(VControl, 16, Index); /* Make it 16 pixels high, std width */
- MoveControl(VControl, temp2Rect.right - temp2Rect.left-15,tempRect.top-1);/* Size it correctly */
- ShowControl(VControl); /* Safe to show it now */
- ValidRect(&(*VControl)->contrlRect); /* Notify Window Manager that it's been drawn */
- HUnlock((Handle)VControl); /* Let it float again */
- }
- }
-
-
-
- /****************************************************************************
-
- Moving windows.
-
- ****************************************************************************/
-
-
- /*
- Move the window.
- Screen and depth may have changed.
- */
-
- MoveTheWindow(whichWindow)
- WindowPtr whichWindow;
- {
- WindowPtr SavePort;
-
- GetPort(&SavePort);
- SetPort(whichWindow);
- SetPort(SavePort);
- }
-
-
-
- /****************************************************************************
-
- Updating windows.
-
- ****************************************************************************/
-
-
- /*
- Update a window.
- */
-
- UpdateTheWindow(whichWindow)
- WindowPtr whichWindow;
- {
- WindowPtr SavePort;
- int windex;
-
- if(whichWindow == (WindowPtr) -1)
- whichWindow = FrontWindow();
-
- windex = findMyWindow(whichWindow);
-
- GetPort(&SavePort); /* Save the current port */
- SetPort(whichWindow); /* Set the port to the window */
-
- BeginUpdate(whichWindow);
-
- if (isLegalWindow(windex))
- {
- if(iconic(windex))
- UpdateIconWindow(whichWindow);
- else
- {
- /* Update Controls and Grow Icon */
- DrawGrowIcon(whichWindow);
- DrawControls(whichWindow);
- DrawGoferIcons(windex);
-
- /* Update TE Area */
- if (TEHANDLE(windex) != NIL)
- TEUpdate(&(*TEHANDLE(windex))->viewRect,TEHANDLE(windex));
- }
-
- }
- else
- {
- /* Update Controls and Grow Icon */
- DrawGrowIcon(whichWindow);
- DrawControls(whichWindow);
- }
-
-
- EndUpdate(whichWindow);
- SetPort(SavePort); /* Restore the old port */
- }
-
-
-
- /*
- Update an iconic window.
- */
-
- UpdateIconWindow(whichWindow)
- WindowPtr whichWindow;
- {
- Rect r, pr;
- int windex = findMyWindow(whichWindow);
- #if 0
- int nwidth = stringwidth(FILENAME(windex)),
- centre;
- #endif
-
- InitWIcon();
-
- if(CWindowIcon == NIL && WindowIcon == NIL)
- return;
-
- pr = ((GrafPtr)whichWindow)->portRect;
-
- SetRect(&r,0,0,32,32);
-
- if(CIAvailable && CWindowIcon != NIL)
- PlotCIcon(&r,CWindowIcon);
- else
- PlotIcon(&r,WindowIcon);
-
- #if 0
- centre = pr.right-pr.left;
-
- ClipRect(&qd.screenBits.bounds);
- SetRect(&r,(centre-nwidth-3)/2+pr.left,pr.bottom,
- (centre+nwidth+3)/2+pr.left,pr.bottom+12);
- EraseRect(&r);
- TextFont(0);
- TextSize(0);
- MoveTo((centre-nwidth)/2+pr.left,pr.bottom+10);
- drawstring(FILENAME(windex));
- #endif
- }
-
-
-
- /****************************************************************************
-
- Activating windows.
-
- ****************************************************************************/
-
- /*
- Activate or deactivate a window.
-
- Changed to handle interpreter-created windows also.
- */
-
- ActivateTheWindow(whichWindow,activate)
- WindowPtr whichWindow;
- int activate;
- {
- WindowPtr SavePort; /* Place to save the last port */
- int windex = findMyWindow(whichWindow);
- extern Boolean wrappedround;
-
- wrappedround = FALSE;
-
- if (isLegalWindow(windex)) /* Only do if the window is ours */
- {
- cantundo();
- GetPort(&SavePort); /* Save the current port */
- SetPort(whichWindow); /* Set the port to my window */
-
- if(iconic(windex))
- {
- UpdateIconWindow(whichWindow);
- SetMenus(activate,windex);
- thefrontwindow = activate?windex:ILLEGAL_WINDOW;
- }
-
- else
- {
- DrawGrowIcon(whichWindow); /* Draw the grow Icon */
-
- SetMenus(activate,windex);
-
- if (activate)
- {
- char theFontName[256];
- TEHandle theInput;
-
- DrawGoferIcons(windex);
-
- /* Show scroll bars */
- ScrollHControl(HSCROLL(windex),whichWindow);
- ScrollVControl(VSCROLL(windex),whichWindow);
-
- thefrontwindow = windex;
- theInput = TEHANDLE(windex);
-
- /* Set font name and size in the font menu */
- getfontname((*theInput)->txFont,theFontName);
- setfontsize((*theInput)->txSize);
- setnewfont(0,theFontName);
-
- /* Activate TextEdit only after font info is set */
- TEActivate(theInput);
- }
- else
- {
- /* Deactivate the Textedit area */
- if (thefrontwindow != ILLEGAL_WINDOW && TEHANDLE(thefrontwindow) != NIL)
- TEDeactivate(TEHANDLE(thefrontwindow));
- thefrontwindow = ILLEGAL_WINDOW;
-
- /* Hide scroll bars */
- if(HSCROLL(windex)!=NIL)
- {
- HideControl(HSCROLL(windex));
- EraseGoferIcons(windex);
- }
-
- if(VSCROLL(windex)!=NIL)
- HideControl(VSCROLL(windex));
- }
- }
-
- SetPort(SavePort); /* Restore the old port */
- InitCursor();
- }
-
- else
- thefrontwindow = ILLEGAL_WINDOW;
-
- AdjustMenus(TRUE);
-
- }
-
-
- /****************************************************************************
-
- Window-specific menu handling.
-
- ****************************************************************************/
-
-
- /*
- Disable or enable a menu item.
- Used to provide context-sensitivity.
- */
-
- disablemenuitem(disable,menu,item)
- Boolean disable;
- MenuHandle menu;
- short item;
- {
- if(disable)
- DisableItem(menu,item);
- else
- EnableItem(menu,item);
- }
-
-
- /*
- Enable/Disable menus appropriate to windex being
- activated/deactivated.
-
- Check/Uncheck the window name in the window menu.
- */
-
- SetMenus(activate,windex)
- int activate;
- int windex;
- {
- if(windex == worksheet)
- {
- disablemenuitem(activate,Menu_File,MItem_Close);
-
- disablemenuitem(activate&&VIRGIN(worksheet),Menu_File,MItem_Save);
- disablemenuitem(activate&&VIRGIN(worksheet),Menu_File,MItem_Revert_to_Saved);
- }
-
- else if (windex == scrap)
- {
- disablemenuitem(activate,Menu_File,MItem_Save);
- disablemenuitem(activate,Menu_File,MItem_Save_As);
- disablemenuitem(activate,Menu_File,MItem_Revert_to_Saved);
- disablemenuitem(activate,Menu_File,MItem_Print);
-
- disablemenuitem(activate,Menu_Find,MItem_Find_Replace);
- disablemenuitem(activate,Menu_Find,MItem_Find_Again);
- disablemenuitem(activate,Menu_Find,MItem_Find_Backwards);
- disablemenuitem(activate,Menu_Find,MItem_Replace_Again);
- }
-
- if(activate && OPEN(windex))
- setitem(Menu_Window,MItem_Iconise,iconic(windex)?"DeIconise":"Iconise");
-
- if((iconic(windex) || isEditWindow(windex)) && OPEN(windex))
- {
- char wtitle[256];
- short menuitem;
-
- getwtitle(WINDOW(windex),wtitle);
- menuitem = findmenuitem(Menu_Window,3,1024,wtitle);
- CheckItem(Menu_Window,menuitem,activate);
- }
- }
-
-
- /****************************************************************************
-
- Locating and processing events for a window.
-
- ****************************************************************************/
-
-
- /*
- Handle mouse events in this window.
- */
-
- DoTheWindow(eventWindow,myEvent)
- WindowPtr eventWindow;
- EventRecord *myEvent;
- {
- short code;
- Point myPt;
- WindowPtr whichWindow;
- ControlHandle theControl;
- int windex = findMyWindow(eventWindow);
-
- if (isLegalWindow(windex))
- {
- /* What happened, where */
- code = FindWindow(myEvent->where, &whichWindow);
-
- if ((myEvent->what == mouseDown) && (eventWindow == whichWindow))
- {
- if(iconic(windex))
- {
- EventRecord mouseUpRec, mouseDownRec;
- long tc = TickCount(), dbltime = GetDblTime();
- thefrontwindow = windex;
-
- do {
- if(!GetNextEvent(mUpMask,&mouseUpRec))
- mouseUpRec.what == nullEvent;
- } while(mouseUpRec.what == nullEvent &&
- mouseUpRec.when < tc+dbltime);
-
- if( mouseUpRec.when < tc+dbltime)
- {
- while((tc=TickCount()) < mouseUpRec.when+dbltime+20)
- {
- if(EventAvail(mDownMask,&mouseDownRec))
- {
- if(mouseDownRec.when-mouseUpRec.when <= dbltime)
- {
- GetNextEvent(mDownMask,&mouseDownRec);
- DeIconiseWindow(windex);
- return;
- }
- }
- }
- }
-
- /* If no double click, drag the window */
- SelectWindow(whichWindow);
- DoDrag(whichWindow);
- return;
- }
-
- /* Activate the window if necessary */
- if(WINDOW(windex) != FrontWindow())
- {
- SelectWindow(whichWindow);
- return;
- }
-
- /* Set the GrafPtr */
- SetPort(whichWindow);
-
- /* Make the mouse position relative to the current window */
- myPt = myEvent->where;
- GlobalToLocal(&myPt);
-
- if(PtInRect(myPt,&((*TEHANDLE(windex))->viewRect)))
- {
-
- if (TEHANDLE(windex) != NIL && isEditWindow(windex))
- {
- Boolean shift = (myEvent->modifiers & shiftKey) != 0;
- TEClick(myPt, shift, TEHANDLE(windex));
- cantundo(); /* Once we've clicked, we can't undo */
- }
-
- thefrontwindow = windex;
- return;
- }
- }
-
- if ((eventWindow == whichWindow) && (code == inContent))
- {
- Rect lockrect, litrect, numrect;
- Rect pr = WINDOW(windex)->portRect;
-
- SetRect(&lockrect,0,pr.bottom-SMALLICONWIDTH,
- SMALLICONWIDTH,pr.bottom);
-
- SetRect(&litrect,SMALLICONWIDTH,pr.bottom-SMALLICONWIDTH,
- SMALLICONWIDTH*2,pr.bottom);
-
- SetRect(&numrect,SMALLICONWIDTH*2,pr.bottom-SMALLICONWIDTH,
- SMALLICONWIDTH*3,pr.bottom);
-
- /* Has the locked icon been pressed (not for the scrap) */
- if(isEditWindow(windex) && PtInRect(myPt,&lockrect))
- InvertLock(windex);
-
- /* or, for normal windows the literate or number icon */
- else if(windex > worksheet && PtInRect(myPt,&litrect))
- InvertLiterate(windex);
-
- else if(windex > worksheet && PtInRect(myPt,&numrect))
- InvertNumber(windex);
-
- /* If not, handle the scrolling */
- else
- {
- /* Handle scrolling */
- code = FindControl(myPt, whichWindow, &theControl);
- DoScroll((short) code,myPt,theControl==VSCROLL(windex));
- }
- }
- }
- else
- SetPort(whichWindow);
- }
-
-
-
- /****************************************************************************
-
- Handling the small icons in the horizontal scrollbar.
-
- ****************************************************************************/
-
-
- /*
- Draw the small locked icon. This is either
-
- Padlock Finder Locked File
- Pencil Writable
- No Pencil Locked Volume or no write access permission
- */
-
- DrawLockedIcon(windex)
- int windex;
- {
- Rect ir = (*HSCROLL(windex))->contrlRect;
- Rect nr = WINDOW(windex)->portRect;
- static Handle vlicon = NIL, flicon = NIL, ulicon = NIL;
- Handle icon;
- BitMap iconbm;
-
- if(!isEditWindow(windex) || iconic(windex))
- return;
-
- if(vlicon==NIL)
- vlicon = GetResource('SICN',Res_IconVLocked);
-
- if(flicon==NIL)
- flicon = GetResource('SICN',Res_IconFLocked);
-
- if(ulicon==NIL)
- ulicon = GetResource('SICN',Res_IconUnlocked);
-
- SetPort(WINDOW(windex));
-
- nr.left = -1; /* Set the icon rect to the left of the window */
- nr.right = SMALLICONWIDTH-1;
- nr.top = nr.bottom-SMALLICONWIDTH;
-
- ir.left = 0;
- ir.right = SMALLICONWIDTH;
- ir.top = 0;
- ir.bottom = SMALLICONWIDTH;
-
- icon = VLOCKED(windex)? vlicon: FLOCKED(windex)? flicon: ulicon;
-
- HLock(icon);
- iconbm.baseAddr = *icon;
- iconbm.rowBytes = 2;
- SetRect(&(iconbm.bounds),0,0,SMALLICONWIDTH,SMALLICONWIDTH);
-
- CopyBits(&iconbm,&(WINDOW(windex)->portBits),&ir,&nr,srcCopy,0);
- HUnlock(icon);
- OffsetRect(&nr,0,1);
- FrameRect(&nr);
- }
-
- /*
- Erase the locked icon area.
- */
-
- EraseLockedIcon(windex)
- int windex;
- {
- Rect nr = WINDOW(windex)->portRect;
-
- /* Not for scrap/icon windows */
- if(!isEditWindow(windex) || iconic(windex))
- return;
-
- nr.left = -1; /* Set the icon rect to the left of the window */
- nr.right = SMALLICONWIDTH-1;
- nr.top = nr.bottom-SMALLICONWIDTH;
- EraseRect(&nr);
- OffsetRect(&nr,0,1);
- FrameRect(&nr);
- }
-
-
- InvertLock(windex)
- int windex;
- {
- if(FILENAME(windex) == NIL)
- return;
-
- /* Can only lock editablw windows */
- if(!isEditWindow(windex) || iconic(windex))
- return;
-
- if(isVolLocked(VREFNUM(windex),DIRID(windex)))
- FLAGS(windex) = (FLAGS(windex) | WVLOCKED) & ~WFLOCKED;
-
- else
- {
- if(FLOCKED(windex))
- {
- if (isUserLocked(FILENAME(windex),VREFNUM(windex),DIRID(windex)))
- SetFileLock(FILENAME(windex),VREFNUM(windex),DIRID(windex),FALSE);
- }
-
- else
- {
- if (!isUserLocked(FILENAME(windex),VREFNUM(windex),DIRID(windex)))
- SetFileLock(FILENAME(windex),VREFNUM(windex),DIRID(windex),TRUE);
- }
-
- if (isUserLocked(FILENAME(windex),VREFNUM(windex),DIRID(windex)))
- FLAGS(windex) = (FLAGS(windex) | WFLOCKED) & ~WVLOCKED;
- else
- FLAGS(windex) &= ~WLOCKED;
- }
-
- DrawLockedIcon(windex);
- }
-
-
- SetFileLock(name,volrefnum,dirID,lock)
- char *name;
- short volrefnum;
- long dirID;
- Boolean lock;
- {
- HFileParam finfo;
- char fname[256];
-
- strcpy(fname,name);
-
- finfo.ioCompletion = NIL;
- finfo.ioNamePtr = c2pstr(fname);
- finfo.ioVRefNum = volrefnum;
- finfo.ioFVersNum = 0;
- finfo.ioFDirIndex = 0;
- finfo.ioDirID = dirID;
-
- if(lock)
- PBHSetFLock((HParmBlkPtr)&finfo,FALSE);
- else
- PBHRstFLock((HParmBlkPtr)&finfo,FALSE);
- }
-
-
- /*
- And similarly for the literate icon
- */
-
- DrawLiterateIcon(windex)
- int windex;
- {
- Rect ir = (*HSCROLL(windex))->contrlRect;
- Rect nr = WINDOW(windex)->portRect;
- static Handle liticon = NIL, nlicon = NIL;
- Handle icon;
- BitMap iconbm;
-
- /* Not for worksheet/scrap */
- if(!isEditWindow(windex) || windex == worksheet || iconic(windex))
- return;
-
- if(liticon==NIL)
- liticon = GetResource('SICN',Res_IconLiterate);
-
- if(nlicon==NIL)
- nlicon = GetResource('SICN',Res_IconNonLiterate);
-
- SetPort(WINDOW(windex));
-
- nr.left = SMALLICONWIDTH-2; /* Set the icon rect after the locked icon */
- nr.right = SMALLICONWIDTH+SMALLICONWIDTH-2;
- nr.top = nr.bottom-SMALLICONWIDTH;
-
- ir.left = 0;
- ir.right = SMALLICONWIDTH;
- ir.top = 0;
- ir.bottom = SMALLICONWIDTH;
-
- icon = LITERATE(windex)? liticon: nlicon;
-
- HLock(icon);
- iconbm.baseAddr = *icon;
- iconbm.rowBytes = 2;
- SetRect(&(iconbm.bounds),0,0,SMALLICONWIDTH,SMALLICONWIDTH);
-
- CopyBits(&iconbm,&(WINDOW(windex)->portBits),&ir,&nr,srcCopy,0);
- HUnlock(icon);
- OffsetRect(&nr,0,1);
- FrameRect(&nr);
- }
-
-
- EraseLiterateIcon(windex)
- int windex;
- {
- Rect nr = WINDOW(windex)->portRect;
-
- /* Not for worksheet/scrap */
- if(!isEditWindow(windex) || windex == worksheet || iconic(windex))
- return;
-
- nr.left = SMALLICONWIDTH-2; /* Set the icon rect after the locked icon */
- nr.right = SMALLICONWIDTH*2-2;
- nr.top = nr.bottom-SMALLICONWIDTH;
- EraseRect(&nr);
- OffsetRect(&nr,0,1);
- FrameRect(&nr);
- }
-
-
- InvertLiterate(windex)
- int windex;
- {
- if(!isEditWindow(windex) || windex == worksheet || iconic(windex))
- return;
-
- if(LITERATE(windex))
- FLAGS(windex) &= ~WLITERATE;
- else
- FLAGS(windex) |= WLITERATE;
- DrawLiterateIcon(windex);
-
- changed(windex);
- }
-
-
- /*
- And the number icon
- */
-
- DrawNumberIcon(windex)
- int windex;
- {
- Rect ir = (*HSCROLL(windex))->contrlRect;
- Rect nr = WINDOW(windex)->portRect;
- static Handle hnumicon = NIL, gnumicon = NIL;
- Handle icon;
- BitMap iconbm;
-
- /* Not for worksheet/scrap */
- if(!isEditWindow(windex) || windex == worksheet || iconic(windex))
- return;
-
- if(hnumicon==NIL)
- hnumicon = GetResource('SICN',Res_IconHaskellNumbers);
-
- if(gnumicon==NIL)
- gnumicon = GetResource('SICN',Res_IconGoferNumbers);
-
- SetPort(WINDOW(windex));
-
- nr.left = SMALLICONWIDTH*2-3; /* Set the icon rect after the locked icon */
- nr.right = SMALLICONWIDTH*3-3;
- nr.top = nr.bottom-SMALLICONWIDTH;
-
- ir.left = 0;
- ir.right = SMALLICONWIDTH;
- ir.top = 0;
- ir.bottom = SMALLICONWIDTH;
-
- icon = FLAGS(windex)&WHNUM? hnumicon: gnumicon;
-
- HLock(icon);
- iconbm.baseAddr = *icon;
- iconbm.rowBytes = 2;
- SetRect(&(iconbm.bounds),0,0,SMALLICONWIDTH,SMALLICONWIDTH);
-
- CopyBits(&iconbm,&(WINDOW(windex)->portBits),&ir,&nr,srcCopy,0);
- HUnlock(icon);
- OffsetRect(&nr,0,1);
- FrameRect(&nr);
- }
-
-
- EraseNumberIcon(windex)
- int windex;
- {
- Rect nr = WINDOW(windex)->portRect;
-
- /* Not for worksheet/scrap */
- if(!isEditWindow(windex) || windex == worksheet || iconic(windex))
- return;
-
- nr.left = SMALLICONWIDTH*2-3; /* Set the icon rect after the locked icon */
- nr.right = SMALLICONWIDTH*3-3;
- nr.top = nr.bottom-SMALLICONWIDTH;
- EraseRect(&nr);
- OffsetRect(&nr,0,1);
- FrameRect(&nr);
- }
-
-
- InvertNumber(windex)
- int windex;
- {
- if(!isEditWindow(windex) || windex == worksheet || iconic(windex))
- return;
-
- if(FLAGS(windex)&WHNUM)
- FLAGS(windex) &= ~WHNUM;
- else
- FLAGS(windex) |= WHNUM;
- DrawNumberIcon(windex);
-
- changed(windex);
- }
-
-
- DrawGoferIcons(windex)
- int windex;
- {
- DrawLockedIcon(windex);
- DrawLiterateIcon(windex);
- DrawNumberIcon(windex);
- }
-
-
- EraseGoferIcons(windex)
- {
- EraseLockedIcon(windex);
- EraseLiterateIcon(windex);
- EraseNumberIcon(windex);
- }
-
-
- /****************************************************************************
-
- Opening Windows.
-
- ****************************************************************************/
-
-
-
- /*
- Open a named window. Probably DEFUNCT.
- */
-
- openwindowcalled(name)
- char *name;
- {
- /* This assumes that the window is on the startup volume -- HSL */
- openthewindow(findMyWindowName(name,(short)0,(long)0,TRUE));
- }
-
-
- /*
- Open an indexed window.
-
- Just select the window if it is legal and "live".
- */
-
- openthewindow(windex)
- int windex;
- {
- if(isLegalWindow(windex) && OPEN(windex))
- {
- if(iconic(windex))
- DeIconiseWindow(windex);
- SelectWindow(WINDOW(windex));
- }
- }
-
-
- /*
- Make a window the frontmost window.
-
- */
-
- windowtofront(windex)
- int windex;
- {
- WindowPtr w = WINDOW(windex);
-
- if(w != FrontWindow())
- {
- if(w != thefrontwindow && thefrontwindow != ILLEGAL_WINDOW)
- ActivateTheWindow(WINDOW(thefrontwindow),FALSE);
- if(iconic(windex))
- DeIconiseWindow(windex);
- SelectWindow(w);
- updatewindows();
- }
- }
-
-
-
- /****************************************************************************
-
- Showing/Hiding Windows.
-
- ****************************************************************************/
-
-
- HideAllWindows(hide)
- Boolean hide;
- {
- int i;
-
- if(scrapVisible)
- ShowHide(iconic(scrap)?ICONWINDOW(scrap):WINDOW(scrap),!hide);
-
- for(i=NUM_SYS_WINDOWS-1; i < NUM_WINDOWS; ++i)
- if(OPEN(i))
- ShowHide(iconic(i)?ICONWINDOW(i):WINDOW(i),!hide);
- }
-